home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15465 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: news.sprintlink.net!datalytics!usenet
  2. From: Rob Stewart <stew@datalytics.com>
  3. Newsgroups: comp.lang.c++,gnu.g++.help
  4. Subject: Re: Unable to compile inline functions
  5. Date: Fri, 05 Apr 1996 12:11:03 -0500
  6. Organization: Datalytics, Inc
  7. Message-ID: <31655427.20FB@datalytics.com>
  8. References: <4js108$pm4@ncar.ucar.edu> <4jt6bf$4cn@clarknet.clark.net>
  9. NNTP-Posting-Host: 204.62.224.71
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Harlan Messinger wrote:
  16. > James Adams (jadams@sage.cgd.ucar.edu) wrote:
  17. > : Hello,
  18. > :
  19. > :       I am attempting to compile a C++ program which has member functions
  20. > : defined as inline, and I get unresolved errors from my linker.  For instance
  21. > : I have a class defined as such:
  22. > :
  23. > When you compile a module that invokes a function that is declared inline
  24. > in a header file, the compiler has to be able to find the inline
  25. > definition in order to handle the code. It's the compiler that converts an
  26. > inline function call into the function's body. But the compiler only knows
  27. > what's in the file it's compiling, so if you put the function's definition
  28. > in a separate file that isn't #included, it's invisible to the compiler.
  29.  
  30. The inline keyword is a suggestion to the compiler.  It is not 
  31. obligated to follow your suggestion.  In this case, the compiler 
  32. silently ignored the inline keyword since it couldn't find the 
  33. definition of the function; it expected the function to be out 
  34. of line instead.  However, in the translation unit that 
  35. contained the function definition, you still indicated that it 
  36. was inline.  As a result, the compiler didn't generate object 
  37. code for that function to be found by the linker for the 
  38. references to it in the other translation units.
  39.  
  40. -- 
  41. Robert Stewart        | My opinions are usually my own.
  42. Datalytics, Inc.    | stew@datalytics.com
  43.